package com.veo.service.Impl;

import com.veo.bean.User;
import com.veo.dao.UserDao;
import com.veo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("userService")
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.READ_UNCOMMITTED)
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;


    public int delUser(int id) {
        System.out.println("userService---delUser");
        return userDao.delUser(id);
    }

    public int updateUserById(User user) {
        System.out.println("userService---updateUserById");
        return userDao.updateUserById(user);
    }

    public int addUser(User user) {
        System.out.println("userService---addUser");
        return userDao.addUser(user);
    }

    public User findUserById(int id) {
        System.out.println("userService---findUserById");
        return userDao.findUserById(id);
    }

    public List<User> findAllUsers() {
        System.out.println("userService---findAllUsers");
        return userDao.findAllUsers();
    }

    public User findUserByNameAndPwd(String username, String pwd) {
        System.out.println("userService---findUserByNameAndPwd");
//        int i = 1/0;
        return userDao.findUserByNameAndPwd(username,pwd);
    }
}
